Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Printing Extensions and Drivers /
Chapter 3 - Printer Drivers / The QuickDraw GX ImageWriter II Printer Driver Messages


Managing Special Page Handling

QuickDraw GX sends the GXStartSendPage message during imaging, just before each page is rendered. The ImageWriter II printer driver overrides this message with the SD_StartSendPage function to manage manual feeding of paper. The SD_StartSendPage function first checks to see if the entire print job uses automatic paper feeding; if not, it determines if the paper type of the page that is about to be rendered is a manually fed paper type. If so, SD_StartSendPage displays a printing alert box, as described in the section "Displaying Status Information and the Printing Alert Boxes" beginning on page 3-41.

The first portion of the SD_StartSendPage function uses the job collection to determine if the entire print job uses automatic paper feeding, as shown in
Listing 3-13. The GXStartSendPage message is described on page 4-136 in the
chapter "Printing Messages."

Listing 3-13 Determining if the print job uses any manually fed pages

{
   OSErr             anErr = noErr;
   gxJob             theJob = GXGetJob();
   Collection        jobCollection;
   gxPaperFeedInfo   paperFeed;
   long              itemSize = sizeof(paperFeed);
   ResType           commType;
   short             statusReturn;

   jobCollection = GetJobCollection(theJob);

   /* cache the communications type */
   commType = (**(SpecGlobalsHdl)
                  GetMessageHandlerInstanceContext()).commType;
   if (commType == 'PPTL')
      {
      FetchStatusString(&statusReturn, true, true);
      nrequire(anErr, FetchStatusString);
      }
   else
      statusReturn = 0;

   /* first, determine if the entire job is auto feed */
   paperFeed.autoFeed = true;
   (void) GetCollectionItem(jobCollection, gxPaperFeedTag,
                           gxPrintingTagID, &itemSize, &paperFeed);
/*
   If the entire job is not auto feed, the value of the
   paperFeed.autoFeed field will now be changed to false.
*/
   .....
If the GetCollectionItem call succeeds in finding a paper-feed item, then the value of the paperFeed.autoFeed field is determined by the retrieved value. Otherwise, the value of the paperFeed.autoFeed field remains true, as it was before making the call. If this field is false, the job includes manual feeding.

The next portion of the SD_StartSendPage function executes if the print job includes any manually fed pages. This portion loops through the list of manual-feed paper-type names and uses the job collection to determine if the entire job uses automatic paper feeding, as shown in Listing 3-14.

Listing 3-14 Finding the manual-feed paper name

   if (!paperFeed.autoFeed)
      {
      /* get the manual-feed list, using the paper-feed size */
      gxManualFeedInfo  **feedHandle;
      
      feedHandle = (gxManualFeedInfo**) NewHandle(0);
      anErr = MemError();
      nrequire(anErr, FailedNewHandle);
      
      anErr = GetCollectionItemHdl(jobCollection, gxManualFeedTag,
                              gxPrintingTagID, (Handle)feedHandle);
      if (anErr == noErr)
         {
         Str31             paperName;
         short             idx;
         gxManualFeedInfo  *pFeed;
         
         /* get name of this page's paper type */
         GXGetPaperTypeName(GXGetFormatPaperType(pageFormat),
                                             paperName);
         
         paperFeed.autoFeed = true;
         
         /* lock and dereference for the loop */
         HLockHi((Handle) feedHandle);
         pFeed = *feedHandle;
         /* look for the manualy fed paper-type name */
         for (idx = 0; idx < pFeed->numPaperTypeNames; ++idx) 
            {
            Ptr pName = &pFeed->paperTypeNames[idx];
            
            if (IUMagIDString( paperName, pName,
                               paperName[0], *pName+1) == 0)
               {
               paperFeed.autoFeed = false;
               break;
               }
            }
         }
      
      DisposHandle((Handle) feedHandle);
      FailedNewHandle:
         ;
      }
If the manual-feed paper-type name is found (if paperFeed.autoFeed is false
after exiting the loop) or if the paper-name list is empty, then the remainder of SD_StartSendPage displays a printing alert box to tell the user to manually feed
the appropriate paper. This portion of the SD_StartSendPage function is shown in the next section. The code for the entire SD_StartSendPage function is found in the QuickDraw GX sample code.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help